Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comply with OpenTelemetry attributes specification #1703

Merged
merged 8 commits into from
Mar 18, 2021

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Mar 16, 2021

Currently attributes that a users tries to add to a Span are ensured to be compliant with the OpenTelemetry specification before they are added to the Span, otherwise they are dropped. This same logic is needed when attributes are used to create resources.

This unifies the logic to check if an attribute is valid in a new Valid method on the attribute.KeyValue type and adds this validation check to the resource package.

The OpenTelemetry specification requires attributes conform to a
standard evaluated and returned by attribute.KeyValue.Valid. To comply
with the specification, Resources created from NewWithAttributes need to
only contain valid attributes. This adds a check to ensure this and
drops invalid attributes passed as arguments.
@codecov
Copy link

codecov bot commented Mar 16, 2021

Codecov Report

Merging #1703 (c1494f6) into main (8888435) will increase coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #1703   +/-   ##
=====================================
  Coverage   77.8%   77.8%           
=====================================
  Files        130     130           
  Lines       6988    6998   +10     
=====================================
+ Hits        5438    5450   +12     
+ Misses      1299    1297    -2     
  Partials     251     251           
Impacted Files Coverage Δ
attribute/kv.go 82.7% <100.0%> (+0.6%) ⬆️
sdk/resource/builtin.go 90.0% <100.0%> (+1.7%) ⬆️
sdk/resource/resource.go 60.7% <100.0%> (+5.2%) ⬆️
sdk/trace/span.go 90.9% <100.0%> (ø)
exporters/otlp/otlpgrpc/connection.go 88.7% <0.0%> (+1.8%) ⬆️

The attribute.Set is (possibly overly) optimized to avoid allocations.
The returned value from the constructor is a value of a Set, not a
pointer to the Set. A Set contains a lock value and pointer methods so
passing the Set value raises the copylock go vet error. This copies the
same nolint comment from the `NewSet` method this used to use.
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@XSAM XSAM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Aneurysm9 Aneurysm9 merged commit 0fe65e6 into open-telemetry:main Mar 18, 2021
@MrAlias MrAlias deleted the attr-valid branch March 18, 2021 15:51
@MrAlias MrAlias mentioned this pull request Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants